home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / asmwin13.zip / DEMO.ASM next >
Assembly Source File  |  1989-01-27  |  23KB  |  681 lines

  1. TITLE 'Video Demo Program'
  2.  
  3. ;
  4. ; This is a short program to demonstrate the VIDEO.ASM TASM Assembler module.
  5. ; You may use VIDDEMO.MAK to automate the assembly of this program.  It is
  6. ; only designed to work in a 80x25 mode. (Video Modes 2, 3, & 7)
  7. ;
  8. ; All lines that make use of VIDEO.ASM routines or VIDEO.INC equates have
  9. ; been marked with ($) so you can scan through this file and see how to
  10. ; use the routine fairly easily.
  11. ;
  12. ; -- Dave
  13. ;
  14. ; ------------------------
  15. ; Jan 23, 1989
  16. ;
  17. ; I have revised this code some, to demo the windowing routines I have
  18. ; added, and to resize the DOS memory to the minimum required by the
  19. ; program.  (This frees memory for the window routines).
  20. ;
  21. ; Tom Hill
  22.  
  23. IDEAL                   ; Use TASM's ideal mode
  24.  
  25. DOSSEG                  ; Use DOS segment ordering
  26.  
  27. MODEL SMALL             ; Small memory model
  28.  
  29. INCLUDE 'VIDEO.INC'     ; Global declarations for VIDEO.ASM
  30.  
  31. ; ------
  32. ; Macros
  33. ; ------
  34.  
  35. MACRO   Pause   Seconds
  36.     LOCAL PauseLoop, KeyFound
  37.     ;
  38.     ; This macro will pause until a key is pressed.
  39.     ;
  40.     ; Uses:
  41.     ;       KeyPressed, ClearKBD
  42.     ;
  43.         push    ax              ; Save regs
  44.         push    cx
  45.     IFNB <Seconds>
  46.         mov     cx, (Seconds*18)+(Seconds/5)    ; 5 is recip of .2!
  47.     ELSE
  48.         mov     cx, 91          ; 5 Seconds
  49.     ENDIF
  50.     PauseLoop:
  51.         call    KeyPressed      ; check for pressed key
  52.         or      al, al          ; Sets the zero flag if null
  53.         jnz     KeyFound        ; loop until key is pressed
  54.         call    Delay           ; Delay for .055 of a second
  55.         loop    PauseLoop
  56.     KeyFound:
  57.         call    ClearKBD        ; Clear the key
  58.         pop     cx              ; Restore registers
  59.         pop     ax
  60. ENDM
  61.  
  62. ; ---------------
  63. ; Program Equates
  64. ; ---------------
  65.  
  66.     Version         EQU     '1.2'
  67.     Date            EQU     '01/23/89'
  68.  
  69.     MaxRows         EQU     25              ; Maximum rows
  70.     CenterRow       EQU     (MaxRows/2)     ; Center row
  71.     MaxCols         EQU     80              ; Maximum columns
  72.     CenterCol       EQU     (MaxCols/2)     ; Center column
  73.     FillRows        EQU     5               ; Number of rows for fill demo
  74.     FillCols        EQU     20              ; Number of cols for fill demo
  75.  
  76. ; -------------
  77. ; Stack Segment
  78. ; -------------
  79.  
  80. STACK   0FFFh
  81.  
  82. ; -------------
  83. ; Data Segement
  84. ; -------------
  85.  
  86. ; NOTE: Program relies on data being in current order.  Do not reorder, delete
  87. ;       or insert new data into the list.  Data can be appended to this segment
  88. ;       definition.
  89.  
  90. DATASEG
  91.  
  92.         WTitle1         DB ' WINDOW #1 ',0
  93.         WTitle2         DB ' No frame ',0
  94.         WTitle3         DB ' #3 Window ',0
  95.     Title1          DB 'VIDEO.ASM - Direct Screen Writing Routines', 0
  96.     LABEL           T1End BYTE
  97.     T1Len           EQU     (T1End-Title1-1)
  98.  
  99.     Title2          DB 'Author: Dave Bennett / CompuServe 74635,1671',0
  100.     LABEL           T2End BYTE
  101.     T2Len           EQU     (T2End-Title2-1)
  102.  
  103.         Title2A         DB 'Windowing routines added by Thomas Hill',0
  104.         LABEL           T2AEnd BYTE
  105.         T2ALen          EQU     (T2AEnd-TItle2A-1)
  106.  
  107.     Title3          DB 'Version ', Version, ' - Date: ', Date, 0
  108.     LABEL           T3End BYTE
  109.     T3Len           EQU     (T3End-Title3-1)
  110.  
  111.     Title4          DB 'Features:', 0
  112.     Title5          DB ' - Video mode detection', 0
  113.     Title6          DB ' - Monochrome/CGA/EGA support', 0
  114.     Title7          DB ' - Snow suppression', 0
  115.     Title8          DB ' - Direct character & string writing', 0
  116.     Title9          DB ' - Screen saving & restoring', 0
  117.     Title10         DB ' - Area fills (character, attribute, and both)', 0
  118.     Title11         DB ' - Cursor on & off control', 0
  119.     Title12         DB ' - All commands w/ or w/o attribute changes',0
  120.  
  121.     Msg             DB 'Direct Screen Writing is Fast!!!', 0
  122.     LABEL           MsgEnd BYTE
  123.     MsgLen          EQU     (MsgEnd-Msg-1)
  124.  
  125.     SaveMsg         DB ' Screen has been saved... ', 0
  126.     LABEL           SMsgEnd BYTE
  127.     SMsgLen         EQU     (SMsgEnd-SaveMsg-1)
  128.  
  129.     CharMsg1        DB ' Character ', 0
  130.     CharMsg2        DB ' Writing!! ', 0
  131.  
  132.     Wheel           DB 179, '/-\', 179, '/-\'  ; Wheel Chars
  133.     LABEL           WheelEnd BYTE
  134.     MaxWheel        EQU     (WheelEnd-Wheel-1)      ; Maximum Wheel offset
  135.  
  136.     FillMsg1        DB '-AREA-', 0
  137.     FillMsg2        DB '-FILL-', 0
  138.  
  139.     RestoreMsg      DB ' Here''s your saved screen image! ', 0
  140.     LABEL           RMsgEnd BYTE
  141.     RMsgLen         EQU     (RMsgEnd - RestoreMsg - 1)
  142.  
  143.     VidModErr       DB 'Invalid Video Mode!', 0Dh, 0Ah, '$'
  144.         MemError        DB 'Cannot resize memory.',0Dh,0Ah,'$'
  145.         BadInit         DB 'Error return from windows init.',0Dh,0Ah,'$'
  146.  
  147.     RDir            DB 0                    ; Row Direction
  148.     CDir            DB 0                    ; Col Direction
  149.  
  150. ; window handles
  151.  
  152.         WHandle1        DB 0
  153.         WHandle2        DB 0
  154.         WHandle3        DB 0
  155.  
  156. ; --------------------------
  157. ; Uninitialized Data Segment
  158. ; --------------------------
  159.  
  160. UDATASEG
  161.  
  162.     LowTick         DW (?)          ; Tick holder for Delay routine
  163.  
  164. ; ------------
  165. ; Code Segment
  166. ; ------------
  167.  
  168. CODESEG
  169.  
  170.     mov     ax, @data       ; Set the
  171.     mov     ds, ax          ;   Data segment
  172.         call    ReSizeMem
  173.     call    GetVideoMode    ; Get vid mode data.  MUST BE CALLED FIRST ($)
  174.  
  175.     cmp     [VideoMode], BW80       ; ($)
  176.     je      VideoMode_OK            ; Video Mode BW80 is ok
  177.     cmp     [VideoMode], CO80       ; ($)
  178.     je      VideoMode_OK            ; Video Mode CO80 is ok
  179.     cmp     [VideoMode], Mono       ; ($)
  180.     je      VideoMode_OK            ; Monochrome is ok
  181.  
  182.     mov     dx, OFFSET VidModErr    ; All other modes are unacceptable
  183.     mov     ah, 09                  ; DOS print string func
  184.     int     21h                     ; Call DOS
  185.     jmp     ErrExit                 ; Exit the program
  186.  
  187. VideoMode_OK:
  188. ;       mov     [SnowCheck], 0  ; No Snow Checking! ($)
  189.     call    CursorOff       ; Turn the cursor off ($)
  190.  
  191. ; --------------------
  192. ; Define some windows
  193. ; --------------------
  194.  
  195.         call    InitWindows
  196.         jnc     Init_OK
  197.         mov     dx,OFFSET BadInit
  198.         mov     ah,09H
  199.         int     21H
  200.         jmp     ErrExit
  201.  
  202. Init_OK:
  203.  
  204.         mov     ax,0A0AH                ; Upper left corner 10,10
  205.         mov     bx,0A0AH                ; ten chars wide, ten rows deep
  206.         mov     cx,0007H                ; save underlay, frame it and clear it
  207.         mov     dh,Reverse              ; frame atrribute
  208.         mov     dl,Normal               ; background
  209.         mov     si,OFFSET WTitle1       ; title one
  210.         call    MakeWindow
  211.         mov     [WHandle1],al           ; save the handle
  212.         mov     ax,0F28H                ; 16,40
  213.         mov     bx,0A20H                ; 10 x 32
  214.         mov     cx,0005H                ; Save & fill, no frame
  215.         mov     dh,Normal               ; no frame, doesn't matter
  216.         mov     dl,Reverse              ; fill in reverse
  217.         mov     si,OFFSET WTitle2       ; second title
  218.         call    MakeWindow
  219.         mov     [WHandle2],al
  220.         mov     ax,0303H
  221.         mov     bx,1440H                ; 20 x 64
  222.         mov     cx,0007H
  223.         mov     dh,Normal
  224.         mov     dl,Reverse
  225.         mov     si,OFFSET WTitle3
  226.         call    MakeWindow
  227.         mov     [WHandle3],al
  228.  
  229. ; ------------
  230. ; Title Screen
  231. ; ------------
  232.  
  233.     call    ClrScr                  ; Clear the screen
  234.     mov     si, (OFFSET Title1)     ; First Message
  235.     mov     bh, Normal              ; Gray on Black ($)
  236.     mov     ah, 1                   ; Start at top row
  237.     mov     al, (CenterCol-(T1Len/2))       ; Center the message
  238.     call    DWriteStr               ; Write without attribute ($)
  239.     inc     ah                      ; Double
  240.     inc     ah                      ;   Space
  241.     mov     al, (CenterCol-(T2Len/2))       ; Center Title Msg 2
  242.  
  243.     ; NOTE: SI Already points to Title2 (See DATASEG)
  244.  
  245.     call    DWriteStr               ; Write the string to the scr ($)
  246.     inc     ah                      ; Single Space
  247.         mov     al, (centerCol-(T2ALen/2))
  248.         call    DWriteStr
  249.         inc     ah
  250.     mov     al, (CenterCol-(T3Len/2))       ; Center title Msg 3
  251.     call    DWriteStr               ; Write string to scr ($)
  252.     inc     ah                      ; Double
  253.     inc     ah                      ;   Space
  254.     mov     al, (CenterCol-(T1Len/2)) ; Align with first row
  255.     call    DWriteStr               ; Write str to scr ($)
  256.     inc     ah                      ; Double
  257.     inc     ah                      ;   Space
  258.     inc     al                      ; Indent
  259.     inc     al                      ;   2 Spaces
  260.     mov     cx, 8                   ; 8 Feature lines
  261. TS_Features:
  262.     call    DWriteStr               ; Write a feature ($)
  263.     inc     ah                      ; Double
  264.     inc     ah                      ;   Space
  265.     loop    TS_Features             ; Loop for all feature lines
  266.  
  267.     Pause   <10>                    ; Wait for a pressed key (10 seconds)
  268.  
  269. ;---------------
  270. ; DFillAttr Demo
  271. ; --------------
  272.  
  273.     cmp     [VideoMode], Mono       ; This code is'nt suited for mono ($)
  274.     je      DWN_Begin               ; So goto DWriteStNA demo if mono
  275.  
  276.     mov     ax, 0101h               ; First row/First column
  277.     mov     bh, MaxRows             ; All rows
  278.     mov     bl, MaxCols             ; All columns
  279.     mov     dh, 1                   ; Initialize attribute
  280.  
  281. DFA_Top:
  282.     and     dh, 00001111b           ; Clear all but foreground
  283.     cmp     dh, 0                   ; Check for no attribute
  284.     jne     DFA_Fill                ; Go ahead if attribute
  285.     inc     dh                      ; Make sure theres and attr
  286. DFA_Fill:
  287.     call    DFillAttr               ; Fill screen with attribute ($)
  288.     call    Delay                   ; Delay for .055 of a second
  289.     inc     dh                      ; Next Attribture
  290.     push    ax                      ; Store row/col info
  291.     call    KeyPressed              ; Check for a key
  292.     or      al, al                  ; Sets zero flag if no char
  293.     pop     ax                      ; Restore row/col info
  294.     jz      DFA_Top                 ; If no key the loop
  295.     call    ClearKBD                ; Clear key(s) from buffer
  296.  
  297. ;-----------------
  298. ; DWriteStrNA Demo
  299. ; ----------------
  300.  
  301. DWN_Begin:
  302.     call    ClrScr          ; Clear the screen
  303.     mov     ax, 0           ; Initialize row/col
  304.     mov     bh, Normal      ; Initialize Attribute ($)
  305.  
  306.  DWN_MoveMsg:
  307.     mov     si, OFFSET Msg  ; Point to Msg
  308.     test    [RDir], 1       ; Check the direction
  309.     jz      DWN_RInc        ; If direction is right then goto RInc
  310.     dec     ah              ; Decrement the row
  311.     cmp     ah, 1           ; Check to see if row eq 1
  312.     jne     DWN_CheckCol    ;   If not then check columns
  313.     inc     [RDir]          ; Change the direction
  314.     jmp     DWN_CheckCol    ; Check columns
  315. DWN_RInc:
  316.     inc     ah              ; Increment the row
  317.     cmp     ah, MaxRows     ; Check to see if row eq MaxRows
  318.     jne     DWN_CheckCol    ;   If not then check columns
  319.     inc     [RDir]          ; Change the row-wise direction
  320. DWN_CheckCol:
  321.     test    [CDir], 1       ; Check column wise direction
  322.     jz      DWN_CInc        ; If direction is down then goto CInt
  323.     dec     al              ; Decrement the row (Go up)
  324.     cmp     al, 1           ; Check to see if this is column one
  325.     jne     DWN_WriteIt     ;   If not then check attr
  326.     inc     [CDir]          ; Change the direction
  327.     jmp     DWN_WriteIt     ; Check the attr
  328. DWN_CInc:
  329.     inc     al              ; Increment the row
  330.     cmp     al, (MaxCols-MsgLen) ; Check to see if row eq MaxCols
  331.     jne     DWN_WriteIt     ;           If not then check attr
  332.     inc     [CDir]          ; Change the column-wise direction
  333. DWN_WriteIt:
  334.     call    DWriteStrNA     ; Write the str on scr w/o attr change ($)
  335.     push    ax              ; Store ax reg
  336.     call    KeyPressed      ; Check to see if a key has been pressed
  337.     or      al, al          ; Does AL eq zero?
  338.     pop     ax              ; Restore registers
  339.     jz      DWN_MoveMsg     ; if Yes then Redisplay message
  340.     call    ClearKBD        ; Clear the keyboard
  341.  
  342. ; --------------
  343. ; DWriteStr Demo
  344. ; --------------
  345.  
  346.     cmp     [VideoMode], Mono       ; Demo not well suited for mono ($)
  347.     je      Windows                 ; so goto window demo if mono
  348.  
  349. DW_MoveMsg:
  350.     mov     si, OFFSET Msg  ; Point to Msg
  351.     test    [RDir], 1       ; Check the direction
  352.     jz      DW_RInc         ; If direction is right then goto RInc
  353.     dec     ah              ; Decrement the row
  354.     cmp     ah, 1           ; Check to see if row eq 1
  355.     jne     DW_CheckCol     ;   If not then check columns
  356.     inc     [RDir]          ; Change the direction
  357.     jmp     DW_CheckCol     ; Check columns
  358. DW_RInc:
  359.     inc     ah              ; Increment the row
  360.     cmp     ah, MaxRows     ; Check to see if row eq MaxRows
  361.     jne     DW_CheckCol     ;   If not then check columns
  362.     inc     [RDir]          ; Change the row-wise direction
  363. DW_CheckCol:
  364.     test    [CDir], 1       ; Check column wise direction
  365.     jz      DW_CInc         ; If direction is down then goto CInt
  366.     dec     al              ; Decrement the row (Go up)
  367.     cmp     al, 1           ; Check to see if this is column one
  368.     jne     DW_CheckAttr    ;   If not then check attr
  369.     inc     [CDir]          ; Change the direction
  370.     jmp     DW_CheckAttr    ; Check the attr
  371. DW_CInc:
  372.     inc     al              ; Increment the row
  373.     cmp     al, (MaxCols - MsgLen) ; Check to see if row eq MaxCols
  374.     jne     DW_CheckAttr     ;           If not then check attr
  375.     inc     [CDir]          ; Change the column-wise direction
  376. DW_CheckAttr:
  377.     inc     bh              ; Increment the attribute
  378.     test    bh, Blink       ; Test to see if blink bit is on
  379.     jz      DW_WriteIt      ; If not then skip to WriteIt
  380.     mov     bh, 1           ; Set BH eq 1
  381. DW_WriteIt:
  382.     call    DWriteStr       ; Write the string on the screen ($)
  383.     push    ax              ; Store ax reg
  384.     call    KeyPressed      ; Check to see if a key has been pressed
  385.     or      al, al          ; Does AL eq zero?
  386.     pop     ax              ; Restore registers
  387.     jz      DW_MoveMsg      ; if Yes then Redisplay message
  388.     call    ClearKBD        ; Clear the keyboard
  389.  
  390.     Pause   <10>            ; Macro to pause for 10 seconds
  391.  
  392. ; --------------------
  393. ; Display some windows
  394. ; --------------------
  395.  
  396. Windows:
  397.         mov     al,[WHandle1]
  398.         call    DispWindow      ; window 1
  399.  
  400.         Pause
  401.  
  402.         mov     al,[WHandle2]
  403.         call    DispWindow
  404.  
  405.         Pause
  406.  
  407.         mov     al,[WHandle3]
  408.         call    DispWindow
  409.  
  410.         Pause
  411.  
  412.         push    si                      ; let's write some strings!
  413.         mov     ax,080AH
  414.         mov     bh,Normal
  415.         mov     bl,8
  416. WLoop:
  417.         mov     si,OFFSET Title4
  418.     mov     cx,8                    ; 8 Feature lines
  419. WLoop2:
  420.     call    WWriteStr               ; Write a feature ($)
  421.     loop    WLoop2                  ; Loop for all feature lines
  422.         dec     bl
  423.         jnz     WLoop                   ; fill up the window, and then some
  424.         pop     si
  425.  
  426.         Pause   <10>
  427.  
  428.  
  429.         call    EraseTopWin
  430.  
  431.         Pause
  432.  
  433.         call    EraseTopWin
  434.  
  435.         Pause
  436.  
  437.         call    EraseTopWin
  438.  
  439.         Pause
  440.  
  441. ; -------------
  442. ; DWriteCH Demo
  443. ; -------------
  444.  
  445.     CharMsg1Col     =       24
  446.     CharMsg2Col     =       48
  447.     RowStart        =       1       ; Row to start in
  448.     ColStart        =       6       ; Column to start in
  449.  
  450.     ; Note: SI already points to CharMsg1 (See DATASEG)
  451.  
  452.     call    ClrScr                  ; Clear the screen
  453.     mov     ah, CenterRow           ; Middle row of screen
  454.     mov     bh, (Brown*10h+Blue)    ; Blue on Brown (Also ul mono) ($)
  455.     mov     al, CharMsg1Col         ; Point to column for first msg
  456.     call    DWriteStr               ; Write the first string ($)
  457.  
  458.     ; Note: SI now points to CharMsg2 (See DATASEG)
  459.  
  460.     mov     al, CharMsg2Col         ; Column for second msg
  461.     call    DWriteStr               ; Write the second string ($)
  462.  
  463.     mov     ah, RowStart            ; Start row
  464.     mov     al, ColStart            ; Start column
  465.     mov     bh, White               ; White on black ($)
  466.     mov     cx, 1                   ; One Character
  467.     mov     si, OFFSET Wheel        ; Offset of wheel characters
  468. DWC_Top:
  469.     mov     bl, [Byte Ptr si]       ; Load character into bl
  470. DWC_WriteIt:
  471.     call    DWriteCH                ; Write the character ($)
  472.     inc     ah                      ; Next row
  473.     inc     al                      ; Next column
  474.     cmp     ah, MaxRows             ; Check AH against Maximum rows
  475.     jle     DWC_CheckCol            ; If less then then Check columns
  476.     mov     ah, 1                   ; Reset row
  477. DWC_CheckCol:
  478.     cmp     al, MaxCols             ; Check AL agains max cols
  479.     jle     DWC_WriteIt             ; If less than max cols then write
  480.     mov     ah, RowStart            ; Reset row
  481.     mov     al, ColStart            ; Reset col
  482. ;       call    Delay                   ; Wait 1 / 18.2 of a second
  483.     inc     si                      ; Point to next character in wheel
  484.     cmp     si, (OFFSET Wheel + MaxWheel)   ; Maximum offset of Wheel
  485.     jle     DWC_Top
  486. DWC_InKey:
  487.     push    ax              ; Store row/col info
  488.     call    KeyPressed      ; Check to see if a key has been pressed
  489.     or      al, al          ; Sets zero flag if al eq 0
  490.     pop     ax              ; Restore row/col info
  491.     jnz     DWC_End         ; If a key has been press (not null) then end
  492.     mov     si, OFFSET Wheel ; Set SI to offset zero of wheel
  493.     jmp     DWC_Top         ; If zero flag set then loop
  494. DWC_End:
  495.     call    ClearKBD        ; Clear the keyboard
  496.  
  497. ; ------------
  498. ; DFillCH Demo
  499. ; ------------
  500.  
  501.     FillMsgCol      =       36      ; Fill Msgs in column 25
  502.     FillMsg1Row     =       3       ; Message one in row 3
  503.     FillMsg2Row     =       20      ; Message two in row 20
  504.     FillWid         =       15      ; Width of fill
  505.     FillHt          =       4       ; Fill Height
  506.     RInc            =       2       ; Row Increment
  507.     CInc            =       7       ; Column Increment
  508.  
  509.     call    ClrScr          ; Clear the screen
  510.     mov     ah, FillMsg1Row ; Row for first msg
  511.     mov     al, FillMsgCol  ; Col for the msg
  512.     mov     bh, LightBlue+Blink ; LightBlue on Black w/ Blink (ul mono) ($)
  513.  
  514.     ; NOTE: SI Points to first msg already
  515.  
  516.     call    DWriteStr       ; Write the first message (SI points to 2nd) ($)
  517.     mov     ah, FillMsg2Row ; Row for the second message
  518.     call    DWriteStr       ; Write the second message to the screen ($)
  519.  
  520.     mov     ax, 0101h       ; Top row / Left Col
  521.     mov     bh, FillHt      ; Number of rows
  522.     mov     bl, FillWid     ; Number of columns
  523.     mov     dh, 00h         ; Initialize attr
  524.  
  525. DFCH_Top:
  526.     inc     dh              ; Increment dh
  527.     mov     dl, dh          ; Move attribute to character
  528.     call    DFillCh         ; Do the fill ($)
  529.     add     ah, RInc        ; Increment rows
  530.     add     al, CInc        ; Increment columns
  531.     cmp     ah, (MaxRows-FillHt)    ; compare ah to max rows - fill ht
  532.     jle     DFCH_CheckCol   ; If less than or equal to then check columns
  533.     jmp     DFCH_SecPart    ; Goto the second part
  534. DFCH_CheckCol:
  535.     cmp     al, (MaxCols-FillWid)   ; compare al to max cols - fill width
  536.     jle     DFCH_Top                ; Jump to the top if in bounds
  537. DFCH_SecPart:
  538.     mov     dh, 0           ; Initialize the attribute
  539.     mov     ah, 1           ; Top Row
  540.     mov     al, (MaxCols-FillWid) ; Right Side
  541. DFCH_Top2:
  542.     inc     dh              ; Increment dh
  543.     mov     dl, dh          ; Move attribute to character
  544.     call    DFillCh         ; Do the fill
  545.     add     ah, RInc        ; Increment rows
  546.     sub     al, CInc         ; Decrement columns
  547.     cmp     ah, (MaxRows-FillHt)    ; compare ah to max rows - fill ht
  548.     jle     DFCH_CheckCol2  ; If less than or equal to then check columns
  549.     jmp     DFCH_Pause      ; Goto the pause routine
  550. DFCH_CheckCol2:
  551.     cmp     al, 1           ; compare al to 1 (First column)
  552.     jg      DFCH_Top2       ; Jump to the top if in bounds
  553. DFCH_Pause:
  554.     Pause   <10>            ; Macro to pause 10 seconds
  555.  
  556. Exit:
  557.         call    EraseTopWin     ; recover first window (original screen)
  558. ErrExit:
  559.     call    CursorOn        ; Turn the cursor on ($)
  560.     mov     ah, 4Ch         ; DOS exit function
  561.     int     21h             ; Call DOS to exit
  562.  
  563. ; -------------------
  564. ; Programs Procedures
  565. ; -------------------
  566.  
  567. PROC ReSizeMem
  568. ;
  569. ; This procedure will calulate the current size of the program,
  570. ; and return the unused memory to the DOS system.
  571. ;
  572.         push    ax
  573.         push    bx
  574.         push    cx
  575.         push    dx
  576.         mov     ah,62H          ; Get PSP Address (DOS 3 and above only)
  577.         int     21H
  578.         mov     ax,SS           ; stack segment
  579.         sub     ax,bx           ; segment difference
  580.         mov     cx,4
  581.         shl     ax,cl           ; make value be bytes
  582.         mov     bx,ax           ; save it
  583.         mov     ax,SP           ; use top of stack as end of program marker
  584.         mov     cx,10H          ; plus some slack
  585.         add     ax,cx
  586.         add     ax,bx           ; figure program size.
  587.         mov     cx,4
  588.         shr     ax,cl           ; make into paragraphs
  589.         mov     bx,ax
  590.         mov     ah,4AH          ; resize allocated memory
  591.         int     21H             ; do it.
  592.         pop     dx
  593.         pop     cx
  594.         pop     bx
  595.         pop     ax
  596.         jnc     ReSizeOK        ; no problems
  597.         mov     dx,OFFSET MemError
  598.         mov     ah,09H
  599.         int     21H
  600.         jmp     ErrExit
  601. ReSizeOK:
  602.         ret
  603.         
  604. ENDP ResizeMem
  605.                         
  606.         
  607.     PROC ClrScr
  608.     ;
  609.     ; This procedure Clears the screen using VIDEO.ASM
  610.     ;
  611.         push    ax              ; Store registers
  612.         push    bx
  613.         push    dx
  614.         mov     ax, 0101h       ; First row & col
  615.         mov     bh, MaxRows     ; All Rows
  616.         mov     bl, MaxCols     ; All Columns
  617.         mov     dh, Normal      ; Attr = Gray on Black ($)
  618.         mov     dl, ' '         ; Fill scr with spaces
  619.         call    DFillCH         ; Do it! ($)
  620.         pop     dx              ; Restore registers
  621.         pop     bx
  622.         pop     ax
  623.         ret
  624.  
  625.     ENDP ClrScr
  626.  
  627.     PROC KeyPressed
  628.     ;
  629.     ; This procedure uses DOS to check if a key has been pressed.
  630.     ;
  631.     ; Output
  632.     ;       AL = FFh/0  Yes/No
  633.     ; Modifies
  634.     ;       AX
  635.     ;
  636.         mov     ah, 0Bh         ; DOS func 0Bh (Check for pressed key)
  637.         int     21h             ; Call DOS
  638.         xor     ah, ah          ; Clear AH reg
  639.         ret
  640.  
  641.     ENDP KeyPressed
  642.  
  643.     PROC ClearKBD
  644.     ;
  645.     ; This procedure uses DOS to clear the keyboard buffer.
  646.     ;
  647.         push    ax              ; Store AX reg
  648.         mov     ax, 0C00h       ; Dos func 0Ch = Clear KBD
  649.         int     21h             ; Call DOS
  650.         pop     ax              ; Restore AX
  651.         ret
  652.  
  653.     ENDP ClearKBD
  654.  
  655.     PROC Delay
  656.     ;
  657.     ; This procedure delays the CPU for about 1 timer tick or 1/18.2 of
  658.     ; of a second.
  659.     ;
  660.         push    ax
  661.         push    cx
  662.         push    dx
  663.         mov     ah,0            ; INT 1A GetTime function
  664.         int     01ah            ; Call timer interrupt
  665.         mov     [LowTick], dx   ; DX returns low timer tick value
  666.     DelayLoop:
  667.         mov     ah, 0           ; INT 1A GetTime function
  668.         int     01ah            ; Call timer interrupt
  669.         cmp     dx, [LowTick]   ; Compare current val to first
  670.         je      DelayLoop       ; If still the same then loop
  671.         pop     dx
  672.         pop     cx
  673.         pop     ax
  674.         ret
  675.  
  676.     ENDP Delay
  677.  
  678.  
  679. END ; Of VidDemo.ASM
  680.  
  681.